/**
 *
 * MobileLib   
 * MainPanelActivity.java
 * Dec 27, 2011
 * @author qidiven
 *
 */
package com.ustc.mobilelib.view;

import android.app.AlertDialog;
import android.app.TabActivity;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

import com.ustc.diven.model.R;

public class MainPanelActivity extends TabActivity{

	private TabHost mth;
	
	private static final String TAB_SEARCH = "search";
	private static final String TAB_MYLIB = "mylib";
	private static final String TAB_NEWBOOK = "newbook";
	private static final String TAB_ABOUT = "about";
	
	public static final String TAG = MainPanelActivity.class.toString();
	
	public RadioGroup radioGroup;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mainpanel);
		init();
	}
	
	private void init()
	{
		mth = this.getTabHost();
		
		TabSpec tsMyLib = mth.newTabSpec(TAB_MYLIB).setIndicator(TAB_MYLIB);
		tsMyLib.setContent(new Intent(MainPanelActivity.this, MyLibActivity.class));
		mth.addTab(tsMyLib);
		
		TabSpec tsNewBook = mth.newTabSpec(TAB_NEWBOOK).setIndicator(TAB_NEWBOOK);
		tsNewBook.setContent(new Intent(MainPanelActivity.this, NewBookActivity.class));
		mth.addTab(tsNewBook);

		TabSpec tsSearch = mth.newTabSpec(TAB_SEARCH).setIndicator(TAB_SEARCH);
		tsSearch.setContent(new Intent(MainPanelActivity.this,SearchActivity.class));
		mth.addTab(tsSearch);
		
		TabSpec tsAbout = mth.newTabSpec(TAB_ABOUT).setIndicator(TAB_ABOUT);
		tsAbout.setContent(new Intent(MainPanelActivity.this,AboutActivity.class));
		mth.addTab(tsAbout);
		
		mth.setCurrentTabByTag(TAB_MYLIB);

		radioGroup = (RadioGroup) findViewById(R.id.main_radio);
		
		radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				// TODO Auto-generated method stub

				switch (checkedId) {
				case R.id.search:
					mth.setCurrentTabByTag(TAB_SEARCH);
					break;
				case R.id.mylib:
					mth.setCurrentTabByTag(TAB_MYLIB);
					break;
				case R.id.new_book:
					mth.setCurrentTabByTag(TAB_NEWBOOK);
					break;
				case R.id.about:
					mth.setCurrentTabByTag(TAB_ABOUT);
					break;
				}
				Log.d(TAG, "select ID" + "===={" + checkedId);
			}
		});
		
	}//end init
	
	
}
